<!DOCTYPE html>


<html lang="zh-CN">


<head>
  <meta charset="utf-8" />
    
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title>
    Django admin后台管理主题美化.md |  
  </title>
  <meta name="generator" content="hexo-theme-ayer">
  
  <link rel="shortcut icon" href="/favicon.ico" />
  
  
<link rel="stylesheet" href="/dist/main.css">

  
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/css/remixicon.min.css">

  
<link rel="stylesheet" href="/css/custom.css">

  
  
<script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>

  
  

  

</head>

</html>

<body>
  <div id="app">
    
      
    <main class="content on">
      <section class="outer">
  <article
  id="post-django/Django admin后台管理主题美化"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  Django admin后台管理主题美化.md
</h1>
 

    </header>
     
    <div class="article-meta">
      <a href="/2020/11/11/django/Django%20admin%E5%90%8E%E5%8F%B0%E7%AE%A1%E7%90%86%E4%B8%BB%E9%A2%98%E7%BE%8E%E5%8C%96/" class="article-date">
  <time datetime="2020-11-10T16:00:00.000Z" itemprop="datePublished">2020-11-11</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/django/">django</a>
  </div>
  
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> 字数统计:</span>
            <span class="post-count">1.2k</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> 阅读时长≈</span>
            <span class="post-count">5 分钟</span>
        </span>
    </span>
</div>
 
    </div>
      
    <div class="tocbot"></div>




  
    <div class="article-entry" itemprop="articleBody">
       
  <h1 id="Django-admin后台管理主题美化"><a href="#Django-admin后台管理主题美化" class="headerlink" title="Django admin后台管理主题美化"></a>Django admin后台管理主题美化</h1><h2 id="SimpleUI"><a href="#SimpleUI" class="headerlink" title="SimpleUI"></a>SimpleUI</h2><p>源码地址：</p>
<p><strong>码云：</strong><a target="_blank" rel="noopener" href="https://gitee.com/tompeppa/simpleui">https://gitee.com/tompeppa/simpleui</a><br><strong>Github：</strong><a target="_blank" rel="noopener" href="https://github.com/newpanjing/simpleui">https://github.com/newpanjing/simpleui</a></p>
<ol>
<li>下载依赖</li>
</ol>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">pip install django-simpleui</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<ol start="2">
<li>配置settings.py</li>
</ol>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">INSTALLED_APPS = [</span><br><span class="line"> <span class="string">&#x27;simpleui&#x27;</span>,</span><br><span class="line"> ....</span><br><span class="line">]</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>重新启动以后你会发现界面已经发生了改变。</p>
<p><img src="https://img-blog.csdnimg.cn/20200320104321704.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzI3NTY1NA==,size_16,color_FFFFFF,t_70#pic_center" alt="在这里插入图片描述"></p>
<p><img src="https://img-blog.csdnimg.cn/20200320104728238.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzI3NTY1NA==,size_16,color_FFFFFF,t_70#pic_center" alt="在这里插入图片描述"></p>
<h2 id="Suit"><a href="#Suit" class="headerlink" title="Suit"></a>Suit</h2><p><strong>1、在你的环境中通过pip安装(注意要安装到项目的环境中)</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip install https://github.com/darklow/django-suit/tarball/v2</span><br></pre></td></tr></table></figure>

<p>可以通过pip freeze或者pip list查看结果</p>
<p><strong>2、在apps.py文件中添加：(my_project_app是指你的项目名称，注意更改)</strong></p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># my_project_app/apps.py</span></span><br><span class="line"><span class="keyword">from</span> suit.apps <span class="keyword">import</span> DjangoSuitConfig</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">SuitConfig</span>(<span class="params">DjangoSuitConfig</span>):</span></span><br><span class="line">    layout = <span class="string">&#x27;horizontal&#x27;</span></span><br></pre></td></tr></table></figure>

<p>layout这个参数决定你的网页是初始样式是垂直样式还是水平样式，可选参数为‘horizontal’或‘vertical’</p>
<p><strong>3、在settings文件里面，在INSTALLED_APPS中添加以下内容：**</strong>(my_project_app是指你的项目名称，注意更改)**</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">INSTALLED_APPS = (</span><br><span class="line">    ...</span><br><span class="line">    <span class="string">&#x27;my_project_app.apps.SuitConfig&#x27;</span>,  <span class="comment"># 需要添加的内容，要放在&#x27;django.contrib.admin&#x27;之前</span></span><br><span class="line">    <span class="string">&#x27;django.contrib.admin&#x27;</span>,</span><br><span class="line">)</span><br></pre></td></tr></table></figure>

<p>保存以上修改，开启项目，按照url进入admin后台，就可以看到后台已经美化了。</p>
<p><img src="https://pic4.zhimg.com/80/v2-2c5a7f4fc2ca70c82970cc52843b737b_720w.jpg" alt="img"></p>
<p><img src="https://pic2.zhimg.com/80/v2-5a67784cb434b448874bde5ccc415df1_720w.jpg" alt="img"></p>
<h2 id="Grappelli"><a href="#Grappelli" class="headerlink" title="Grappelli"></a>Grappelli</h2><p>快速启动指南</p>
<ul>
<li><p>为了使用Grappelli2.11.1，应该提前安装好Django1.11版本并且Admin 站点管理被激活。</p>
<h2 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h2></li>
<li><p>在线安装</p>
</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">pip install django-grappelli(此方法将默认安装最新发布版本)</span><br><span class="line">pip install django-grappelli&#x3D;&#x3D;2.11.1(按照自己所需版本进行安装)12</span><br></pre></td></tr></table></figure>

<ul>
<li><p>安装包下载（本地安装），如果需要下载最新的安装包，可前往github进行选择下载（<a target="_blank" rel="noopener" href="https://github.com/sehmaschine/django-grappelli">安装包下载</a>）</p>
<h2 id="配置"><a href="#配置" class="headerlink" title="配置"></a>配置</h2></li>
<li><p>配置文件<strong>settings.py</strong>并且添加<strong>grappelli</strong>到你的<strong>INSTALLED_APPS</strong>中（在django.contrib.admin之前，否则无法生效）</p>
</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">INSTALLED_APPS &#x3D; [</span><br><span class="line">    &#39;grappelli&#39;, #需位于admin APP之前</span><br><span class="line">    &#39;jango.contrib.admin&#39;,</span><br><span class="line">    &#39;django.contrib.auth&#39;,</span><br><span class="line">    &#39;django.contrib.contenttypes&#39;,</span><br><span class="line">    &#39;django.contrib.sessions&#39;,</span><br><span class="line">    ...</span><br><span class="line">]</span><br><span class="line">123456789</span><br></pre></td></tr></table></figure>

<ul>
<li><p><strong>添加URL模式</strong>，The grappelli URLs是相关查找和自动完成所必需的。你的admin管理界面通过定义admin.site的路由信息才得以使用：</p>
<p><strong>django==2.*后的写法</strong></p>
</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">from django.urls import path</span><br><span class="line">urlpatterns &#x3D; [</span><br><span class="line">    path(&#39;grappelli&#x2F;&#39;, include(&#39;grappelli.urls&#39;)), # grappelli URLS</span><br><span class="line">    path(&#39;admin&#x2F;&#39;, admin.site.urls), # admin site</span><br><span class="line">]</span><br><span class="line"></span><br><span class="line">focus on： 目前django最新发布版本为2.1系列，2.0之前路由配置使用url()函数，2.0之后使用path()函数；1234567</span><br></pre></td></tr></table></figure>

<ul>
<li><p><strong>添加请求上下文处理器</strong>（仪表板（用词不准）和 用户切换所需）-(项目生成后在setting.py文件中已默认处理)</p>
<p><a target="_blank" rel="noopener" href="http://www.2xkt.com/documents/django_182/topics/templates.html">django1.8中文文档-模板详细介绍</a></p>
</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">TEMPLATES &#x3D; [</span><br><span class="line">    &#123;</span><br><span class="line">        &#39;BACKEND&#39;: &#39;django.template.backends.django.DjangoTemplates&#39;,</span><br><span class="line">        &#39;DIRS&#39;: [os.path.join(BASE_DIR, &#39;templates&#39;)]</span><br><span class="line">        ,</span><br><span class="line">        &#39;APP_DIRS&#39;: True,</span><br><span class="line">        &#39;OPTIONS&#39;: &#123;</span><br><span class="line">            &#39;context_processors&#39;: [</span><br><span class="line"></span><br><span class="line">                &#39;&#39;&#39;</span><br><span class="line"></span><br><span class="line">                &#39;django.template.context_processors.request&#39;,</span><br><span class="line"></span><br><span class="line">                &#39;&#39;&#39;</span><br><span class="line">            ],</span><br><span class="line">        &#125;,</span><br><span class="line">    &#125;,</span><br><span class="line">]123456789101112131415161718</span><br></pre></td></tr></table></figure>

<ul>
<li>收集媒体文件</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">python manage.py collectstatic1</span><br></pre></td></tr></table></figure>

<p>focus on:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line">在执行collectstatic之前，需要对静态文件进行配置</span><br><span class="line">collectstatic的作用是把所有单独APP下的静态文件收集到同一个地方进行维护，大概配置过程如下：</span><br><span class="line"></span><br><span class="line"> 1. 确保静态文件处理APP存在与于INSTALLED_APPS 中</span><br><span class="line"> INSTALLED_APPS &#x3D; [</span><br><span class="line">    &#39;django.contrib.staticfiles&#39;</span><br><span class="line">]</span><br><span class="line"> 2. 静态文件路由及绝对路径配置</span><br><span class="line"> STATIC_ROOT &#x3D; os.path.join(BASE_DIR, &#39;static&#39;)</span><br><span class="line"> STATIC_URL &#x3D; &#39;&#x2F;static&#x2F;&#39;</span><br><span class="line"></span><br><span class="line">3.用户上传图片及文件等媒体文件配置</span><br><span class="line"> MEDIA_ROOT &#x3D; os.path.join(BASE_DIR, &quot;static&#x2F;media&quot;)</span><br><span class="line"> MEDIA_URL &#x3D; &quot;&#x2F;media&#x2F;&quot;</span><br><span class="line"></span><br><span class="line">4.调试模式下开启静态文件服务</span><br><span class="line">from django.conf.urls import url, include</span><br><span class="line">from django.contrib import admin</span><br><span class="line">from django.conf import settings</span><br><span class="line">from django.conf.urls.static import static</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">urlpatterns &#x3D; [</span><br><span class="line">    url(r&#39;^admin&#x2F;&#39;, admin.site.urls),</span><br><span class="line">]</span><br><span class="line">urlpatterns +&#x3D; static(settings.STATIC_URL, document_root&#x3D;settings.STATIC_ROOT)</span><br><span class="line">urlpatterns +&#x3D; static(settings.MEDIA_URL, document_root&#x3D;settings.MEDIA_ROOT)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">123456789101112131415161718192021222324252627282930</span><br></pre></td></tr></table></figure>

<p>至此配置成功</p>
<ul>
<li><img src="https://img-blog.csdn.net/20180607104714728?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3N1bl9kYW5neWFuZw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt="查看"></li>
</ul>
<p><img src="https://img-blog.csdn.net/20180607105030917?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3N1bl9kYW5neWFuZw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt="查看"></p>
<h2 id="Xadmin"><a href="#Xadmin" class="headerlink" title="Xadmin"></a>Xadmin</h2><p>xadmin安装</p>
<p>xadmin在github的源码地址<a target="_blank" rel="noopener" href="https://github.com/sshwsfc/xadmin,%E5%8F%AF%E4%BB%A5%E7%94%A8pip%E5%AE%89%E8%A3%85%E4%B9%9F%E5%8F%AF%E4%BB%A5%E8%87%AA%E5%B7%B1%E4%B8%8B%E8%BD%BD%E5%90%8E%E5%AF%BC%E5%85%A5%E5%88%B0%E9%A1%B9%E7%9B%AE%E4%B8%AD%E3%80%82">https://github.com/sshwsfc/xadmin,可以用pip安装也可以自己下载后导入到项目中。</a><br>这里不推荐pip安装，会有报错。本篇介绍下载xadmin后导入的django项目中的方法。</p>
<p>先在github上下载源码包，由于小编的django版本是2.1版本，下载对应的django2分支代码。<br><strong>这里不能直接下载master分支。</strong></p>
<p><strong>下载了后解压出来，只需要里面的xadmin这一部分内容</strong></p>
<p><img src="https://img2020.cnblogs.com/blog/1713532/202004/1713532-20200414155531141-882122585.png" alt="img"></p>
<p> 在原来的django项目下新建一个extra_appa目录，将xadmin文件放入此目录下</p>
<p><strong><img src="https://img2020.cnblogs.com/blog/1713532/202004/1713532-20200414155455635-623741493.png" alt="img"></strong></p>
<p>接着在pycharm上把extra_apps包Mark为Sources Root。具体操作方法：extra_apps右键-找到Mark Directory As-选择Sources Root</p>
<p> <img src="https://img2020.cnblogs.com/blog/1713532/202004/1713532-20200414161242150-113678294.png" alt="img"></p>
<p>在解压的文件里requirements.txt有列出相关的依赖包，用pip安装</p>
<ul>
<li>django-crispy-forms&gt;=1.6.0</li>
<li>django-import-export&gt;=0.5.1</li>
<li>django-reversion&gt;=2.0.0</li>
<li>django-formtools==1.0</li>
<li>future==0.15.2</li>
<li>httplib2==0.9.2</li>
<li>six==1.10.0</li>
</ul>
<p>添加xadmin配置</p>
<p>在项目setting.py中INSTALLED_APPS下注册2个app，xadmin和crispy_forms</p>
<p><img src="https://img2020.cnblogs.com/blog/1713532/202004/1713532-20200414161537699-133982227.png" alt="img"></p>
<p> 找到BASE_DIR这行，修改前代码如下</p>
<p><img src="https://img2020.cnblogs.com/blog/1713532/202004/1713532-20200414161717389-340095278.png" alt="img"></p>
<p> 修改后的代码如下</p>
<p><img src="https://img2020.cnblogs.com/blog/1713532/202004/1713532-20200414161817386-1084287754.png" alt="img"></p>
<p> setting.py设置成中文</p>
<p><img src="https://img2020.cnblogs.com/blog/1713532/202004/1713532-20200414161955877-1458575744.png" alt="img"></p>
<p>urls.py中配置路由</p>
<p><img src="https://img2020.cnblogs.com/blog/1713532/202004/1713532-20200414161900016-1831809193.png" alt="img"></p>
<p>打开xadmin后台</p>
<p>在浏览器输入<a target="_blank" rel="noopener" href="http://localhost:8000/xadmin/%E5%9C%B0%E5%9D%80%EF%BC%8C%E5%B0%B1%E5%8F%AF%E4%BB%A5%E6%89%93%E5%BC%80xadmin%E7%9A%84%E5%90%8E%E5%8F%B0%E4%BA%86">http://localhost:8000/xadmin/地址，就可以打开xadmin的后台了</a></p>
<p><img src="https://img2020.cnblogs.com/blog/1713532/202004/1713532-20200414162152042-43398442.png" alt="img"></p>
<p> 账号和密码和以前admin账号密码一致</p>
<p><img src="https://img2020.cnblogs.com/blog/1713532/202004/1713532-20200414162449862-491106788.png" alt="img"></p>
 
      <!-- reward -->
      
      <div id="reword-out">
        <div id="reward-btn">
          打赏
        </div>
      </div>
      
    </div>
    

    <!-- copyright -->
    
    <div class="declare">
      <ul class="post-copyright">
        <li>
          <i class="ri-copyright-line"></i>
          <strong>版权声明： </strong>
          
          本博客所有文章除特别声明外，著作权归作者所有。转载请注明出处！
          
        </li>
      </ul>
    </div>
    
    <footer class="article-footer">
       
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=http://example.com/2020/11/11/django/Django%20admin%E5%90%8E%E5%8F%B0%E7%AE%A1%E7%90%86%E4%B8%BB%E9%A2%98%E7%BE%8E%E5%8C%96/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>  
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/django/" rel="tag">django</a></li></ul>

    </footer>
  </div>

   
  <nav class="article-nav">
    
      <a href="/2020/11/11/django/8-%E5%89%8D%E5%90%8E%E7%AB%AF%E5%88%86%E7%A6%BB%E5%BC%80%E5%8F%91%E5%85%A5%E9%97%A8/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            8-前后端分离开发入门.md
          
        </div>
      </a>
    
    
      <a href="/2020/11/11/docker/10%20%E4%B8%AA%E5%86%B7%E9%97%A8%E4%BD%86%E5%8F%88%E9%9D%9E%E5%B8%B8%E5%AE%9E%E7%94%A8%E7%9A%84%20Docker%20%E4%BD%BF%E7%94%A8%E6%8A%80%E5%B7%A7/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">10 个冷门但又非常实用的 Docker 使用技巧.md</div>
      </a>
    
  </nav>

   
<!-- valine评论 -->
<div id="vcomments-box">
  <div id="vcomments"></div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/valine@1.4.14/dist/Valine.min.js"></script>
<script>
  new Valine({
    el: "#vcomments",
    app_id: "",
    app_key: "",
    path: window.location.pathname,
    avatar: "monsterid",
    placeholder: "给我的文章加点评论吧~",
    recordIP: true,
  });
  const infoEle = document.querySelector("#vcomments .info");
  if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
    infoEle.childNodes.forEach(function (item) {
      item.parentNode.removeChild(item);
    });
  }
</script>
<style>
  #vcomments-box {
    padding: 5px 30px;
  }

  @media screen and (max-width: 800px) {
    #vcomments-box {
      padding: 5px 0px;
    }
  }

  #vcomments-box #vcomments {
    background-color: #fff;
  }

  .v .vlist .vcard .vh {
    padding-right: 20px;
  }

  .v .vlist .vcard {
    padding-left: 10px;
  }
</style>

 
     
</article>

</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2015-2020
        <i class="ri-heart-fill heart_icon"></i> TzWind
      </li>
    </ul>
    <ul>
      <li>
        
        
        
        由 <a href="https://hexo.io" target="_blank">Hexo</a> 强力驱动
        <span class="division">|</span>
        主题 - <a href="https://github.com/Shen-Yu/hexo-theme-ayer" target="_blank">Ayer</a>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>访问人数:<span id="busuanzi_value_site_uv"></span></s>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>浏览次数:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
      </li>
    </ul>
  </div>
</footer>
      <div class="float_btns">
        <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

      </div>
    </main>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ayer-side.svg" alt="Hexo"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" target="_blank" rel="noopener" href="http://www.baidu.com">百度</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/friends">友链</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/2019/about">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="搜索">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <script>
      if (window.matchMedia("(max-width: 768px)").matches) {
        document.querySelector('.content').classList.remove('on');
        document.querySelector('.sidebar').classList.remove('on');
      }
    </script>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    
  </div>
</div>
    
<script src="/js/jquery-2.0.3.min.js"></script>


<script src="/js/lazyload.min.js"></script>

<!-- Tocbot -->


<script src="/js/tocbot.min.js"></script>

<script>
  tocbot.init({
    tocSelector: '.tocbot',
    contentSelector: '.article-entry',
    headingSelector: 'h1, h2, h3, h4, h5, h6',
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: 'main',
    positionFixedSelector: '.tocbot',
    positionFixedClass: 'is-position-fixed',
    fixedSidebarOffset: 'auto'
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css">
<script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js"></script>

<script src="/dist/main.js"></script>

<!-- ImageViewer -->

<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script>

<!-- MathJax -->

<!-- Katex -->

<!-- busuanzi  -->


<script src="/js/busuanzi-2.3.pure.min.js"></script>


<!-- ClickLove -->

<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->


<link rel="stylesheet" href="/css/clipboard.css">

<script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>


<!-- CanvasBackground -->


    
  </div>
</body>

</html>